package com.x86.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.x86.domain.BC;
import com.x86.mapper.BCMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.x86.domain.Batch;
import com.x86.mapper.BatchMapper;
import com.x86.service.BatchService;

/**
 * @author 风亦未止
 * @date 2022/4/10 19:27
 */
@Service
public class BatchServiceImpl extends ServiceImpl<BatchMapper, Batch> implements BatchService {
    @Autowired
    public BatchMapper batchMapper;

    @Autowired
    public BCMapper bcMapper;

    @Override
    public Integer getLastId() {
        return batchMapper.getLastId();
    }

    @Override
    public void already(String cid) {
        Batch batch = batchMapper.selectById(getLastId());
        batch.setAlready(batch.getAlready() + 1);
        batchMapper.updateById(batch);
        BC bc = new BC(cid, getLastId());
        bcMapper.insert(bc);
    }

    @Override
    public List<Batch> getInfo() {
        return batchMapper.selectList(new QueryWrapper<>());
    }
}

